﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ProjScan.Submodules.Shader_Analysis
{
	// Token: 0x0200017A RID: 378
	public class SAKeywordLine
	{
		// Token: 0x06000D3F RID: 3391 RVA: 0x0003B13C File Offset: 0x0003933C
		public string GetPragma()
		{
			string result;
			switch (this.pragmaType)
			{
			case PragmaType.MultiCompileGlobal:
				result = "#pragma multi_compile ";
				break;
			case PragmaType.MultiCompileLocal:
				result = "#pragma multi_compile_local ";
				break;
			case PragmaType.FeatureGlobal:
				result = "#pragma shader_feature ";
				break;
			case PragmaType.FeatureLocal:
				result = "#pragma shader_feature_local ";
				break;
			default:
				result = "";
				break;
			}
			return result;
		}

		// Token: 0x06000D40 RID: 3392 RVA: 0x0003B198 File Offset: 0x00039398
		public SAKeyword GetKeyword(string name)
		{
			int count = this.keywords.Count;
			for (int i = 0; i < count; i++)
			{
				SAKeyword sakeyword = this.keywords[i];
				bool flag = sakeyword.name.Equals(name);
				if (flag)
				{
					return sakeyword;
				}
			}
			return null;
		}

		// Token: 0x06000D41 RID: 3393 RVA: 0x0003B1F0 File Offset: 0x000393F0
		public void Add(SAKeyword keyword)
		{
			bool flag = this.GetKeyword(keyword.name) != null;
			if (!flag)
			{
				keyword.foundInShaderScript = true;
				bool flag2 = false;
				for (int i = 0; i < keyword.name.Length; i++)
				{
					bool flag3 = keyword.name[i] != '_';
					if (flag3)
					{
						flag2 = true;
						break;
					}
				}
				keyword.isMultiCompile = (this.pragmaType == PragmaType.MultiCompileGlobal || this.pragmaType == PragmaType.MultiCompileLocal);
				bool flag4 = flag2;
				if (flag4)
				{
					keyword.isGlobal = (this.pragmaType != PragmaType.FeatureLocal && this.pragmaType != PragmaType.MultiCompileLocal && this.pragmaType > PragmaType.Unknown);
					keyword.verboseName = keyword.name + " (";
					bool flag5 = !string.IsNullOrEmpty(keyword.shaderGraphName);
					if (flag5)
					{
						keyword.verboseName = keyword.verboseName + keyword.shaderGraphName + ", ";
					}
					keyword.verboseName += (keyword.isMultiCompile ? "multi_compile" : "shader_feature");
					keyword.verboseName += (keyword.isGlobal ? ", global)" : ", local)");
					this.keywords.Add(keyword);
				}
				else
				{
					keyword.isUnderscoreKeyword = true;
					this.hasUnderscoreVariant = true;
				}
				bool flag6 = this.pragmaType == PragmaType.FeatureGlobal || this.pragmaType == PragmaType.FeatureLocal;
				if (flag6)
				{
					bool flag7 = this.keywords.Count == 1;
					if (flag7)
					{
						this.generateDefaultUnderscoreKW = true;
					}
					else
					{
						this.generateDefaultUnderscoreKW = false;
					}
				}
			}
		}

		// Token: 0x06000D42 RID: 3394 RVA: 0x00006BD8 File Offset: 0x00004DD8
		public void DisableKeywords()
		{
			this.keywords.ForEach(delegate(SAKeyword obj)
			{
				obj.enabled = false;
			});
		}

		// Token: 0x06000D43 RID: 3395 RVA: 0x00006C06 File Offset: 0x00004E06
		public void Clear()
		{
			this.keywords.Clear();
		}

		// Token: 0x06000D44 RID: 3396 RVA: 0x0003B39C File Offset: 0x0003959C
		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < this.keywords.Count; i++)
			{
				bool flag = i > 0;
				if (flag)
				{
					stringBuilder.Append(" ");
				}
				stringBuilder.Append(this.keywords[i].name);
			}
			return stringBuilder.ToString();
		}

		// Token: 0x17000341 RID: 833
		// (get) Token: 0x06000D45 RID: 3397 RVA: 0x0003B408 File Offset: 0x00039608
		public int keywordCount
		{
			get
			{
				return this.keywords.Count;
			}
		}

		// Token: 0x17000342 RID: 834
		// (get) Token: 0x06000D46 RID: 3398 RVA: 0x0003B428 File Offset: 0x00039628
		public int keywordsEnabledCount
		{
			get
			{
				int count = this.keywords.Count;
				int num = 0;
				for (int i = 0; i < count; i++)
				{
					bool enabled = this.keywords[i].enabled;
					if (enabled)
					{
						num++;
					}
				}
				return num;
			}
		}

		// Token: 0x04000818 RID: 2072
		public const string PRAGMA_MULTICOMPILE_GLOBAL = "#pragma multi_compile ";

		// Token: 0x04000819 RID: 2073
		public const string PRAGMA_MULTICOMPILE_LOCAL = "#pragma multi_compile_local ";

		// Token: 0x0400081A RID: 2074
		public const string PRAGMA_FEATURE_GLOBAL = "#pragma shader_feature ";

		// Token: 0x0400081B RID: 2075
		public const string PRAGMA_FEATURE_LOCAL = "#pragma shader_feature_local ";

		// Token: 0x0400081C RID: 2076
		public List<SAKeyword> keywords = new List<SAKeyword>();

		// Token: 0x0400081D RID: 2077
		public bool hasUnderscoreVariant;

		// Token: 0x0400081E RID: 2078
		public bool generateDefaultUnderscoreKW = false;

		// Token: 0x0400081F RID: 2079
		public PragmaType pragmaType;
	}
}
